/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: 26727
 * Date: 2025-02-12
 * Time: 22:48
 */
public class BankAccount {
    // Private attributes: only accessible within this class.
    private String iban;
    private int balance; // balance is stored in cents

    // Constructor: accepts the IBAN and initializes balance to 0.
    public BankAccount(String iban) {
        this.iban = iban;
        this.balance = 0;
    }

    // Method to deposit money (amount is in cents).
    // It checks that the deposit amount is positive.
    public void deposit(int amount) {
        if (amount <= 0) {
            System.out.println("Einzahlung abgebrochen. Einzuzahlender Betrag negativ.");
            return;
        }
        balance += amount;
    }

    // Method to withdraw money (amount is in cents).
    // It checks that there is sufficient balance.
    public void withdraw(int amount) {
        if (amount > balance) {
            System.out.println("Auszahlung abgebrochen. Kontostand zu niedrig.");
            return;
        }
        balance -= amount;
    }

    // Method to return the current balance.
    public int getBalance() {
        return balance;
    }
}
